<%--
  Created by IntelliJ IDEA.
  User: 懒瑶瑶
  Date: 2022/5/8
  Time: 20:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>周报</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script>
        // var util;
        layui.use(['table','util','jquery','layer','form'],function () {
            var table = layui.table,util=layui.util,$=layui.jquery,layer=layui.layer,form=layui.form;
            form.verify({
                num_sz:[
                    /(^$)|^\d+$/,
                    '只能填写数字'
                ],
            });
            //监听工具栏的按钮  查看
            table.on('tool(demo)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var worklogId = row.worklogId;
                if(event=='look'){//如果是查看
                    layer.open({
                        type:2,
                        fix:false,
                        maxmin:true,
                        offset:'10px',
                        shadeClose:true,
                        shade:0.4,
                        area:['800px','600px'],
                        title:"查看",
                        content:'${pageContext.request.contextPath}/emp/tolookweekly/'+worklogId
                    });
                }
            });


            //    转载table
            var tabBoss = table.render({
                elem:'#tableData',//指定id选择器
                cols:[[
                    {field:'worklogId',title:'编号'},
                    {field:'empName',title:'名称'},
                    {field:'workday',title:'填写日期',templet:function(d){
                            return util.toDateString(d.workday,'yyyy年MM月dd日'
                            )}},
                    {field:'weekCur',title:'本周情况描述 '},
                    {field:'studentQuestion',title:'问题学生情况反馈 '},
                    {field:'idea',title:'意见建议 '},
                    {field:'weekNext',title:'下周工作计划 '},
                    {toolbar:'#tools',title:'操作',width:150,align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/weekly',//请求路径
                method:'post',//请求方法
                page:true,//显示分页主键
                limits:[5,10,15,20,25,30],//切换每页行数
                limit:10,//默认的没页行数
                loading:true,//数据加载效果样式

            });
            //监听form表单数据
            form.on('submit(search-btn)',function (d) {
                var worklogId = $("#worklogId").val();
                var empName = $("#empName").val();
                var depName = $("#depName").val();
                // alert(empId + empName);
                table.reload('tableData',{//指定条件重载table
                    page: {curr:1},
                    where:{ //条件
                        worklogId:worklogId,
                        empName:empName,
                        depName:depName,
                    }
                });
            });
            //监听form表单提交  模糊查询  查看全部按钮
            form.on('submit(shuaxin-btn)',function (d) {
                location.reload("demo");//重新加载父页面表格
            });
        });
    </script>
</head>
<body><br/>
<div>
    <form class="layui-form" action="${pageContext.request.contextPath}">
        <div class="layui-inline" style="font-weight:bold;font-size: 16px">编号：</div>
        <div class="layui-inline">
            <input type="text" name="worklogId" id="worklogId" class="layui-input"  lay-verify="num_sz"/>
        </div>

        <div class="layui-inline" style="font-weight:bold;font-size: 16px">名称：</div>
        <div class="layui-inline">
            <input type="text" name="empName" id="empName" class="layui-input"/>
        </div>

        <div class="layui-inline" style="font-weight:bold;font-size: 16px">部门：</div>
        <div class="layui-inline" style="width: 130px">
            <%--            <input type="text" name="depId" id="depId" class="layui-input"/>--%>
            <div class="layui-input-inline">
                <select name="depName" id="depName">
                    <option value="">- 请 - 选 - 择 -</option>
                    <c:forEach items="${dlist}" var="s">
                        <option value="${s.depName}">${s.depName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <a class="layui-btn layui-btn-normal layui-icon layui-icon-search" lay-filter="search-btn" lay-submit lay-size="sm">搜索</a>
        <a 	class="layui-btn layui-btn-warm layui-icon layui-icon-refresh" lay-filter="shuaxin-btn" lay-submit lay-size="sm">刷新</a>
    </form>
</div>

<table  class="layui-table" id="tableData" lay-filter="demo" lay-size="sm"></table>
<%--    定义工具栏--%>
<script type="text/html" id="tools">
    <a class="layui-btn layui-btn-sm" lay-event="look">查看周报</a>
</script>
</body>
</html>
